<?php

namespace StudyBuddy;

/**
 * Class responsible for generating an html block
 * which is used for the post signin with Twitter
 * modal with form
 */
class RegBlockTwitter extends RegBlock {

    protected function prepareVars() {

        $this->aVars = array(
            'externalAccount' => $this->makeBlockExternal(),
            /* 'token' => $_SESSION['token'], */
            'title' => 'Welcome to ' . $this->oRegistry->Ini->SITE_NAME,
            'header2' => '<div class="step2">Step 2: Provide Email Address</div>'
        );

        $this->addUsernameBlock();
        d('cp');
        return $this;
    }

    /**
     * Make html block with data about
     * external Twitter account (avatar, username)
     *
     * @return string html block
     */
    protected function makeBlockExternal() {
        d('oViewer: ' . print_r($this->oViewer, 1));

        $aVals = array(
            'Twitter',
            $this->oViewer->getAvatarImgSrc(),
            $this->oViewer->getTwitterUsername()
        );

        d('$aVals: ' . print_r($aVals, 1));

        $s = \tplAvatarblock::parse($aVals, false);

        return $s;
    }

}
